public class StudentDriver3{
	public static void main(String[] args) {
        Student[] studentArray = new Student[5];
        studentArray[0] = new Student(200012, "Farouq Khan",2.0);
        studentArray[1] = new Student(200010, "Qasim Yusuf",3.2);
        studentArray[2] = new Student(200015, "Bakari Saleem",4.0);
        studentArray[3] = new Student(200013, "Ahmad Muhammad",3.5);
        studentArray[4] = new Student(200011, "Daud Abdullatif",2.5);

        Student student1 = new Student(); // Create a dummy object
        student1.setID(200013);

        int index = linearSearch(studentArray, student1);


        if(index >= 0){
            System.out.println("Student with id "
               + student1.getID() + " found, details are: ");
        	    System.out.println(studentArray[index]);
        }
        else
        	System.out.println("Student with id "
                 + student1.getID() + " not found");

        gpaGreaterThan3(studentArray);
    }

    public static int linearSearch(Student[] studentArray, Student student){
    	for(int k = 0; k < studentArray.length; k++)
    		if(student.equals(studentArray[k]))
    			return k;

    	return -1;
    }

    public static void gpaGreaterThan3(Student[] studentArray){
           int k;
           for(k = 0; k < studentArray.length; k++){  // find the first student with GPA > 3.0
        	if(studentArray[k].getGPA() > 3.0){
        	   break;
        	}
            }

           if(k <= studentArray.length - 1){         // if a student with GPA > 3 exists
        	System.out.println("\nStudent(s) with GPA > 3.0 are: ");    // display the header
        	for(int m = k; m < studentArray.length; m++)       // then find the remaining students with GPA > 3 if any
        	        if(studentArray[m].getGPA() > 3.0)
        	            System.out.println(studentArray[m]);
        }
        else
        	System.out.println("\nThere are no students with GPA > 3.0");
    }
}
